// app.js
import {
  BleDscpUtils
} from './common/utils/BleDscpUtils';
let bleDscpUtils = new BleDscpUtils();
let isAppInBackground = false;

App({
  onLaunch: function () {
    my.getSystemInfo({
      success: e => {
        console.info(e)
        this.globalData.StatusBar = e.statusBarHeight;
        let capsule = my.getMenuButtonBoundingClientRect();
        console.info(capsule)
        if (capsule) {
          this.globalData.Custom = capsule;
          this.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;
        } else {
          this.globalData.CustomBar = e.statusBarHeight + 50;
        }
      }
    })
  },

  onShow: function () {
    console.log("App on Show")
    if (isAppInBackground) {
      isAppInBackground = false;
    }
  },

  onHide: function () {
    isAppInBackground = true;
    console.info("---appjs---onHide")
    bleDscpUtils.stopSearch();
  },

  onError(msg) {
    console.log(msg)
  },

  globalData: {
    userInfo: null,
    stopCloseBleConnect: false,
  }
})
